﻿using System;
using System.ComponentModel;
using System.Linq;
using ProjectEuler.Linq;

namespace ProjectEuler.Problems
{
    [EulerProblem(2, 4613732L)]
    [Description("Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.")]
    internal sealed class Problem002 : EulerProblem
    {
        public override Object Solve()
        {
            return
                Integers.Fibonacci(1, 2)
                .Where(Numeric.IsEven)
                .TakeWhile(n => n <= 4000000)
                .Sum();
        }
    }
}
